<!-- 批次库存查询 - 综合表单页面 -->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="superTablePage">

    </ex_super_table_page>

  </div>
</template>
<script>
import { mapState } from "vuex";


export default {
  title: 'title_stock_change_flow',
  components: {},
  data() {
    return {

      option: {
        search: {
          model: [
            { label: "label_sku", key: "skuId", type: 'sku_selec_input' },
            {label: "label_business_type", key: "bizType", type: 'select', enum: 'BizTypeEnum'},
            {
              label: "label_stock_change_type", key: "changeType", type: 'select', enum: 'StockChangeTypeEnum', attrs: { clearable: true },
            },

            {
              label: "label_change_time", key: "time1", type: 'date-picker', //
              attrs: {  type: "datetime" }
            },
            {
              label: "", key: "time2", type: 'date-picker', //
              attrs: { type: "datetime" }
            },
          ],
        },

        table: {
          url: "/oms-api/client/OmsStockQueryClientRpc/stockBatchLogQuery.json",
          attrs: {},
      
          model: [
            {
              key: 'warehouseId', label: 'label_warehouse', align: 'left', 'width': 150,
              attrs: {
                formatter: (r, c, v, i) => this.$formatNameCode(this.allWarehouseMap[v].name, this.allWarehouseMap[v].code)
              }
            },
            {
              key: 'skuOnlyCode', label: 'label_sku_only_code',  align: 'left', 'min-width': 150,
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
              }
            },
            {
              key: 'skuBarcode', label: 'label_sku_code', align: 'left',  'width': 150,
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
              }
            },
            {
              key: 'skuName', label: 'label_sku_name_cn', align: 'left',  'width': 150,
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
              }
            },
            {
              key: 'skuNameEn', label: 'label_sku_name_en', align: 'left',  'width': 150,
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
              }
            },
            {
              key: 'batchNo', label: 'label_batch_code',align: 'left','width': 150,
            },
            {
              key: 'refType', label: 'label_related_order',align: 'left','min-width': 150,
              attrs: {
                formatter: (r, c, v, i) => { return this.$enumShow(v, 'OrderTypeEnum') + ' ' + r.refCode }
              }
            },
            // {
            //   key: 'refCode', label: '关联单据号',
            // },
            {
              key: 'changeType', label: 'label_change_type','width': 140,
              attrs: {
                formatter: (r, c, v, i) => { return this.$enumShow(v, 'StockChangeTypeEnum') }
              }
            },
            {
              key: 'gmtModify', label: 'label_change_time','width': 140,
              attrs: {
                formatter: (r, c, v, i) => { return this.$dateFormat(v) }
              }
            }, 
            {
              key: 'freezeQty', label: 'label_frozen_count','width': 110,
              attrs: {
                formatter: (r, c, v, i) => this.formatQty(v, r.modifyFreezeQty)
              }
            },
            {
              key: 'lockQty', label: 'label_lock_count','width': 110,
              attrs: {
                formatter: (r, c, v, i) => this.formatQty(v, r.modifyLockQty)
              }
            },
            {
              key: 'usableQty', label: 'label_usable_count','width': 110,
              attrs: {
                formatter: (r, c, v, i) => this.formatQty(v, r.modifyUsableQty)
              }
            },
            {
              key: 'totalQty', label: 'label_sum','width': 110,
              attrs: {
                formatter: (r, c, v, i) => this.formatQty(v, r.modifyFreezeQty + r.modifyLockQty + r.modifyUsableQty)
              }
            },
          ],

        }
        ,

      },


    };
  },
  computed: {
    ...mapState({ allWarehouseMap: state => state.allWarehouseMap }),
  },
  methods: {
    // mergeFreezeAndLockNum(freezeQty, lockQty) {
    //   return freezeQty + lockQty
    // },
    formatQty(qty, modifyQty) {
      if (modifyQty > 0) {
        return qty + "(+" + modifyQty + ")"
      }
      else if (modifyQty < 0) {
        return qty + "(" + modifyQty + ")"
      }
      return qty
    }
  }
};

</script>
<style></style>
